function [dataTrain,labelsTrain,dataTest,labelsTest,timestamps] = TrainTestDataSet(filename,value_interval_new,i)
%根据文件名和引用范围，生成训练、测试数据集
%生成时间戳和对应的行，为最后生成csv备用

data = readtable(filename);

timestamps=data(:,1);
data=data(:,2:end);
data=table2array(data);

%对数据进行预处理，添加指标若干
%[26]生成标签
data(:,end+1)=data(:,2)-data(:,5);
%[27]速度指标
data(:,end+1)=sign(data(:,8))+sign(data(:,9))+sign(data(:,10))+sign(data(:,8)-0.1);
%[28]反料仓速度加权均值
data(:,end+1)=(abs(data(:,27)).*data(:,8)+data(:,9)+data(:,10))./3;

data_process=data(:,value_interval_new);

% 分离标签和特征值
labels = data_process(:, 1);
features = data_process(:, 2:end);

% 随机分割数据集
switch i
    case 1
        rng(1);
    case 2
        rng(12);
    case 3
        rng(123);
    case 4
        rng(1234);
    case 5
        rng(12345);
    case 6
        rng(123456);
    case 7
        rng(1234567);
    case 8
        rng(12345678);
    case 9
        rng(123456789);
    case 10
        rng(1234567890);
end

cv = cvpartition(labels,'Holdout',0.3);
idxTrain = training(cv);
idxTest = test(cv);
dataTrain = features(idxTrain,:);
labelsTrain = labels(idxTrain,:);
dataTest = features(idxTest,:);
labelsTest = labels(idxTest,:);

timestamps=timestamps(idxTest,:);

end